#version 300 es

#ifdef GL_ES
precision mediump float;
#endif

#define PI 3.1415926
#define TWO_PI 6.28318530718

uniform vec2 u_resolution;
uniform float u_time;
float minStep = 0.01;

out vec4 outColor;

void main() {

  float solution = min(u_resolution.x, u_resolution.y);
  minStep = 1.0 / solution;
  vec2 st = (gl_FragCoord.xy - u_resolution / 2.0) * minStep;
  vec2 s = vec2(1.0, 1.0) - step(0.5, abs(st));
  if(s.x * s.y < 0.00001) {
    discard;
  }

  vec3 color = vec3(0.0);

  vec2 pos = st;

  float r = length(pos) * 2.0;
  float a = atan(pos.y, pos.x);
  a = mod(a + TWO_PI, TWO_PI);
  // a = a / TWO_PI;
  // color = vec3(a);

  float f = cos(a * 3.0);
    // color = vec3(f*0.5 + 0.5);

  // f = abs(cos(a * 6.0))*0.2 + 0.3;
  // f = abs(cos(a * 2.5)) * 0.5 + 0.3;
  // f = abs(cos(a * 6.0) * sin(a * 3.0)) * 0.8 + 0.1;
  // f = smoothstep(-0.5, 1.0, cos(a * 10.0)) * 0.2 + 0.5;

  color = vec3(1.0 - smoothstep(f, f + minStep * 10.0, r));
  // color = vec3(step(f, r));

  // color = vec3(f);

  outColor = vec4(color, 1.0);
}
